package com.expand.demo

import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.CompoundButton
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
//import butterknife.BindView
//import butterknife.ButterKnife
//import butterknife.OnClick
import com.expand.demo.edit.EditTextActivity
import com.expand.demo.edit.ScrollEditTextActivity
import com.expand.demo.expandable.ExpandableActivity
import com.expand.demo.expandable.MoreLineTextActivity
import com.expand.demo.round.RoundActivity
import com.expand.demo.stroke.LineTextActivity
import com.expand.demo.stroke.StrokeTextActivity
import com.expand.demo.toolbar.ToolbarActivity
import com.rich.widget.ExpandCheckBox
import com.rich.widget.SwitchButton

//import kotlinx.android.synthetic.main.activity_main.*

/**
 * zhu jie mian.
 */
class MainActivity : AppCompatActivity() {

    //    @JvmField
//    @BindView(R.id.cb_checked_all)
    var cbCheckedAll: ExpandCheckBox? = null

    //    @JvmField
//    @BindView(R.id.sb_plug)
    var sbPlug: SwitchButton? = null

    //    @JvmField
//    @BindView(R.id.sb_plug_click)
    var sbPlugClick: SwitchButton? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
//        ButterKnife.bind(this)
        cbCheckedAll = findViewById(R.id.cb_checked_all)
        sbPlug = findViewById(R.id.sb_plug)
        sbPlugClick = findViewById(R.id.sb_plug_click)


        cbCheckedAll!!.setOnBoxCheckedChangeListener(object :
            ExpandCheckBox.OnBoxCheckedChangeListener {
            override fun onBoxCheckedChanged(buttonView: CompoundButton?, isChecked: Boolean) {
                Toast.makeText(this@MainActivity, "isChecked:$isChecked", Toast.LENGTH_SHORT).show()
            }
        })

        sbPlug!!.setOnCheckedChangeListener(object : SwitchButton.OnCheckedChangeListener {
            override fun onCheckedChanged(view: SwitchButton?, isChecked: Boolean) {

            }

            override fun onTouchCheckedChanged(view: SwitchButton?, isChecked: Boolean) {
                Toast.makeText(this@MainActivity, "sbPlugIsChecked:$isChecked", Toast.LENGTH_SHORT)
                    .show()
//                Log.i(TAG, "onTouchCheckedChanged: $isChecked")
            }
        })
        sbPlugClick!!.setOnClickListener {
            Toast.makeText(
                this@MainActivity,
                "setOnClickListener:" + sbPlugClick!!.isChecked,
                Toast.LENGTH_SHORT
            ).show()
        }
        val btn_input = findViewById<View>(R.id.btn_input)
        btn_input.setOnClickListener {
            EditTextActivity.jumpTo(this)
        }
        val btn_toolbar = findViewById<View>(R.id.btn_toolbar)
        btn_toolbar.setOnClickListener {
            ToolbarActivity.jumpTo()
        }
        findViewById<Button>(R.id.btnRound).setOnClickListener {
            RoundActivity.jumpTo(this)
        }
        findViewById<Button>(R.id.btnMoreLine).setOnClickListener {
            ExpandableActivity.jumpTo(this)
        }
        findViewById<Button>(R.id.btnStroke).setOnClickListener {
            StrokeTextActivity.jumpTo(this)
        }
        findViewById<Button>(R.id.btnLine).setOnClickListener {
            LineTextActivity.jumpTo(this)
        }
        findViewById<Button>(R.id.btnNum).setOnClickListener {
            NumberActivity.jumpTo(this)
        }

        //MoreLineTextActivity.jumpTo(this)
        ScrollEditTextActivity.jumpTo(this)
    }

    //@OnClick(R.id.button, R.id.btn_switch, R.id.btn_switch_none)
    fun onViewClicked(view: View) {
        when (view.id) {
            R.id.button -> {
                cbCheckedAll!!.setSimpleChecked(!cbCheckedAll!!.isChecked)
            }

            R.id.btn_switch -> {
                sbPlug!!.isChecked = !sbPlug!!.isChecked
            }

            R.id.btn_switch_none -> {
                sbPlugClick!!.isChecked = !sbPlugClick!!.isChecked
            }
        }
    }
}